package com.ruoyi.project.mgcmanage.controller;


import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.mgcmanage.domain.Purchase;
import com.ruoyi.project.mgcmanage.domain.Supplier;
import com.ruoyi.project.mgcmanage.service.IPurchaseService;
import com.ruoyi.project.mgcmanage.service.ISupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/mgcmanage/purchase")
public class PurchaseController extends BaseController {

    @Autowired
    private IPurchaseService iPurchaseService;

    /**
     * 分页查询采购入库
     * @param purchase
     * @return
     */
    @PreAuthorize("@ss.hasPermi('mgcmanage:purchase:query')")
    @GetMapping("/list")
    public TableDataInfo getList(Purchase purchase){
        startPage();
        return getDataTable(iPurchaseService.getList(purchase));
    }

    /**
     * 在新增药品页面做数据回显
     * @param noId
     * @return
     */
    @PreAuthorize("@ss.hasPermi('mgcmanage:purchase:query')")
    @GetMapping("/{noId}")
    public AjaxResult SelectById(@PathVariable int noId){

        return AjaxResult.success(iPurchaseService.selectById(noId));
    }

    /**
     * 单据作废
     * @param noIds
     * @return
     */
    @PreAuthorize("@ss.hasPermi('mgcmanage:purchase:delete')")
    @DeleteMapping("/{noIds}")
    public AjaxResult deleteStorage(@PathVariable int[] noIds){
        return toAjax(iPurchaseService.deleteStorage(noIds));
    }




}
